home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / PROGENV / ClassItem.C next >
C/C++ Source or Header  |  1992-06-25  |  2KB  |  106 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "ClassItem.h"
  6.  
  7. #include "Class.h"
  8. #include "PrintManager.h"
  9. #include "String.h"
  10.  
  11. //---- PeClassItem -----------------------------------------------------
  12.  
  13. NewMetaImpl(PeClassItem, TextItem, (TP(cl)));
  14.  
  15. PeClassItem::PeClassItem(int id, Class *c, char *label) 
  16.     : TextItem(id, c->Name(), 
  17.         gFixedFont->WithFace(c->IsAbstract() ? eFaceItalic : eFacePlain),
  18.         Point(2,1))
  19. //                gBorder)
  20. {
  21.     cl= c;
  22.     if (label)
  23.     SetString(label);
  24. }
  25.  
  26. char *PeClassItem::ClassName()
  27. {
  28.     return cl->Name();
  29. }
  30.  
  31. int PeClassItem::Compare(Object *op)
  32. {
  33.     return StrCmp((byte*)ClassName(), (byte*)Guard(op, PeClassItem)->ClassName(), -1, sortmap);
  34. }
  35.  
  36. bool PeClassItem::IsEqual(Object *b)
  37. {
  38.     return b->IsKindOf(PeClassItem) &&
  39.         StrCmp((byte*)ClassName(), (byte*)((PeClassItem*)b)->ClassName()) == 0;
  40. }
  41.  
  42. Metric PeClassItem::GetMinSize()
  43. {
  44.     if (TestFlag(eClItemCollapsed))
  45.     return Metric(Point(8));
  46.     return TextItem::GetMinSize();
  47. }
  48.  
  49. #include "LOOKS/MotifLook.h"
  50. #include "Look.h"
  51. void PeClassItem::DrawInner(Rectangle r, bool highlight)
  52. {
  53.     bool coll= TestFlag(eClItemCollapsed);
  54.     if (!GrHasColor()) {
  55.     if (coll)
  56.         GrPaintRect(ContentRect().Inset(2), ePatGrey50);
  57.     else {
  58.         GrPaintRect(ContentRect(), gInkWhite/*gLook->GetBackgroundColor()*/);
  59.         TextItem::Draw(r);
  60.     }
  61.     }
  62.     if (highlight && ! gPrinting)
  63.     DrawHighlight(r);
  64.     if (GrHasColor()) {
  65.     if (coll)
  66.         GrPaintRect(ContentRect().Inset(2), ePatGrey50);
  67.     else {
  68.         if (!highlight)
  69.         GrPaintRect(ContentRect(), gInkWhite /*gLook->GetBackgroundColor()*/);
  70.         TextItem::Draw(r);
  71.     }
  72.     }
  73. //    BevelRect(contentRect, 2, TRUE, new_Grey(0.15), new_Grey(0.95));
  74. }
  75.  
  76. //---- ObjectItem --------------------------------------------------------------
  77.  
  78. NewMetaImpl(PeObjectItem, TextItem, (TP(op)));
  79.  
  80. PeObjectItem::PeObjectItem(int id, Object *o, Font *fp)
  81.                     : TextItem(id, 0, fp, Point(2,1))
  82. {
  83.     char buf[200];
  84.     buf[0]= '\0';
  85.     op= o;
  86.     op->InspectorId(buf, sizeof(buf));
  87.     if (strlen(buf))
  88.     SetFString(FALSE, "0x%x %s", int(op), buf);
  89.     else
  90.     SetFString(FALSE, "0x%x", int(op));
  91. }
  92.  
  93. PeObjectItem::PeObjectItem(int id, char *msg, Object *o, Font *fp)
  94.                     : TextItem(id, 0, fp, Point(2,1))
  95. {
  96.     op= o;
  97.     SetString(msg);
  98. }
  99.  
  100. PeObjectItem::PeObjectItem(char *iv, Object *o, Font *fp)
  101.                     : TextItem(cIdNone, 0, fp, Point(4,0))
  102. {
  103.     op= o;
  104.     SetFString(FALSE, "%s 0x%x", iv, int(op));    
  105. }
  106.